package com.example.mydy.model;

import java.util.Date;

/**
 * 用户特权奖励设置模型类
 * 用于存储特定用户的自定义奖励参数
 */
public class UserRewardPrivilege {
    private int id;
    private String username;  // 用户名
    private double level1Ratio;  // 一级分成比例
    private double level2Ratio;  // 二级分成比例
    private double level3Ratio;  // 三级分成比例
    private double inviteReward;  // 邀请奖励
    private Date startDate;  // 开始时间
    private Date endDate;    // 结束时间（null表示永久有效）
    private String remark;   // 备注说明
    private Date createdAt;  // 创建时间
    
    public UserRewardPrivilege() {
        this.createdAt = new Date();
    }
    
    public UserRewardPrivilege(int id, String username, double level1Ratio, double level2Ratio, 
                             double level3Ratio, double inviteReward, Date startDate, 
                             Date endDate, String remark) {
        this.id = id;
        this.username = username;
        this.level1Ratio = level1Ratio;
        this.level2Ratio = level2Ratio;
        this.level3Ratio = level3Ratio;
        this.inviteReward = inviteReward;
        this.startDate = startDate;
        this.endDate = endDate;
        this.remark = remark;
        this.createdAt = new Date();
    }
    
    // 判断特权是否在有效期内
    public boolean isValid() {
        Date now = new Date();
        return (startDate == null || !now.before(startDate)) && 
               (endDate == null || !now.after(endDate));
    }
    
    // getter和setter方法
    public int getId() {
        return id;
    }
    
    public void setId(int id) {
        this.id = id;
    }
    
    public String getUsername() {
        return username;
    }
    
    public void setUsername(String username) {
        this.username = username;
    }
    
    public double getLevel1Ratio() {
        return level1Ratio;
    }
    
    public void setLevel1Ratio(double level1Ratio) {
        this.level1Ratio = level1Ratio;
    }
    
    public double getLevel2Ratio() {
        return level2Ratio;
    }
    
    public void setLevel2Ratio(double level2Ratio) {
        this.level2Ratio = level2Ratio;
    }
    
    public double getLevel3Ratio() {
        return level3Ratio;
    }
    
    public void setLevel3Ratio(double level3Ratio) {
        this.level3Ratio = level3Ratio;
    }
    
    public double getInviteReward() {
        return inviteReward;
    }
    
    public void setInviteReward(double inviteReward) {
        this.inviteReward = inviteReward;
    }
    
    public Date getStartDate() {
        return startDate;
    }
    
    public void setStartDate(Date startDate) {
        this.startDate = startDate;
    }
    
    public Date getEndDate() {
        return endDate;
    }
    
    public void setEndDate(Date endDate) {
        this.endDate = endDate;
    }
    
    public String getRemark() {
        return remark;
    }
    
    public void setRemark(String remark) {
        this.remark = remark;
    }
    
    public Date getCreatedAt() {
        return createdAt;
    }
    
    public void setCreatedAt(Date createdAt) {
        this.createdAt = createdAt;
    }
    
    @Override
    public String toString() {
        return "UserRewardPrivilege{" +
                "id=" + id +
                ", username='" + username + '\'' +
                ", level1Ratio=" + level1Ratio +
                ", level2Ratio=" + level2Ratio +
                ", level3Ratio=" + level3Ratio +
                ", inviteReward=" + inviteReward +
                ", valid=" + isValid() +
                '}';
    }
} 